package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.service.domain.KtserviceViphallTag;
import com.ktgj.service.service.IKtserviceViphallTagService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 贵宾厅service标签	Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/tag")
public class KtserviceViphallTagController extends BaseController
{
    @Autowired
    private IKtserviceViphallTagService KtserviceViphallTagService;

    /**
     * 查询贵宾厅service标签列表
     */
    //@PreAuthorize(hasPermi = "service:tag:list")
    @GetMapping("/list")
    public TableDataInfo list(KtserviceViphallTag KtserviceViphallTag)
    {
        startPage();
        List<KtserviceViphallTag> list = KtserviceViphallTagService.selectKtserviceViphallTagList(KtserviceViphallTag);
        return getDataTable(list);
    }

    /**
     * 导出贵宾厅service标签列表
     */
    //@PreAuthorize(hasPermi = "service:tag:export")
    @Log(title = "贵宾厅service标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KtserviceViphallTag KtserviceViphallTag) throws IOException
    {
        List<KtserviceViphallTag> list = KtserviceViphallTagService.selectKtserviceViphallTagList(KtserviceViphallTag);
        ExcelUtil<KtserviceViphallTag> util = new ExcelUtil<KtserviceViphallTag>(KtserviceViphallTag.class);
        util.exportExcel(response, list, "贵宾厅service标签数据");
    }

    /**
     * 获取贵宾厅service标签详细信息
     */
    //@PreAuthorize(hasPermi = "service:tag:query")
    @PostMapping("/getInfo")
    public AjaxResult getInfo(@RequestBody Map<String, Object> map)
    {
        Long tagId = Long.valueOf(map.get("tagId").toString());
        return AjaxResult.success(KtserviceViphallTagService.selectKtserviceViphallTagById(tagId));
    }

    /**
     * 新增贵宾厅service标签
     * */
    //@PreAuthorize(hasPermi = "service:tag:add")
    @Log(title = "贵宾厅service标签", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody KtserviceViphallTag KtserviceViphallTag)
    {
        int i = KtserviceViphallTagService.insertKtserviceViphallTag(KtserviceViphallTag);
        if (i > 0){
            return AjaxResult.success("添加成功");
        }
        else {
            return AjaxResult.error("添加失败");
        }
    }

    /**
     * 修改贵宾厅service标签
     * */
    //@PreAuthorize(hasPermi = "service:tag:edit")
    @Log(title = "贵宾厅service标签", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody KtserviceViphallTag KtserviceViphallTag)
    {
        int i = KtserviceViphallTagService.updateKtserviceViphallTag(KtserviceViphallTag);
        if (i > 0){
            return AjaxResult.success("修改成功");
        }
        else {
            return AjaxResult.success("修改失败");
        }
    }

    /**
     * 删除贵宾厅service标签
     * */
    //@PreAuthorize(hasPermi = "service:tag:remove")
    @Log(title = "贵宾厅service标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tagIds}")
    public AjaxResult remove(@PathVariable Long[] tagIds)
    {
        return toAjax(KtserviceViphallTagService.deleteKtserviceViphallTagByIds(tagIds));
    }

    /**
     * 删除贵宾厅标签
     * */
    @PostMapping("/delRemove")
    public AjaxResult delRemove(@RequestBody Map<String, Object> map) {
        Long tagId = Long.valueOf(map.get("id").toString());
        return toAjax(KtserviceViphallTagService.deleteKtserviceViphallTagById(tagId));
    }

    /**
     * 贵宾厅标签排序号升序操作
     */
    @GetMapping("/updateTagSort")
    public AjaxResult updateKtserviceViphallTagByTagsort(Long tagId){
        return AjaxResult.success(KtserviceViphallTagService.updateKtserviceViphallTagByTagsort(tagId));
    }

    /**
     * 贵宾厅标签排序号升序操作
     */
    @GetMapping("/updateTagSorts")
    public AjaxResult updateKtserviceViphallTagByTagsorts(Long tagId){
        return AjaxResult.success(KtserviceViphallTagService.updateKtserviceViphallTagByTagsorts(tagId));
    }

    /**
     * 弹窗列表（标签）
     * */
    @PostMapping("/selectViphallTag")
    public TableDataInfo selectViphallTag(@RequestBody Map<String, Object> map){
        startPage();
        String name = null;
        if (map.get("name") != null && !map.get("name").equals("")){
            name = map.get("name").toString();
        }
        List<KtserviceViphallTag> ktserviceViphallTagList = KtserviceViphallTagService.selectViphallTag(name);
        return getDataTable(ktserviceViphallTagList);
    }
}
